/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biofilter.records;

import biofilter.util.StringUtil;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author qvh
 */
public class BowTieRecordTest {

    public BowTieRecordTest() {

    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    private String line = "HWI-EAS127_3_4_1_774_879\t-\tctg93  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]\t419184\tAANTTGACCGCCTGGGGAGTACGGTCGCAAGATTAAAACTC \t IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\t2\t38:G>N,37:C>A\n";
    private String line2 = "HWI-EAS127_3_4_1_774_879\t-\tctg94  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]\t97654\tAANTTGACCGCCTGGGGAGTACGGTCGCAAGATTAAAACTC \t IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII\t2\t38:G>N\n";
    private String line3 = "HWI-EAS127_3_4_1_774_879\t-\tctg95  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]\t58243 \tAANTTGACCGCCTGGGGAGTACGGTCGCAAGATTAAAACTC \t IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII  \t     2   \t    38:G>N\n";
    private String line4 = "HWI-EAS127_3_4_1_774_879\t+\tctg95  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]\t1786951 \tGAGTTTTAATCTTGCGACCGTACTCCCCAGGCGGTCAANTT \t IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII  \t     2   \t    38:C>N\n";
    private String line5 = "HWI-EAS127_3_4_1_774_879\t+\tctg95  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]\t2816492\tGAGTTTTAATCTTGCGACCGTACTCCCCAGGCGGTCAANTT \t IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII     \t  2    \t   38:C>N\n";
    private String line6 = "HWI-EAS127_3_4_1_774_879\t+\tctg95  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]\t3048770\tGAGTTTTAATCTTGCGACCGTACTCCCCAGGCGGTCAANTT \t IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII     \t  2    \t   38:C>N";
    private BowTieRecord instance = null;
    @Before
    public void setUp() {
        instance = new BowTieRecord(line);
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of set method, of class BowTieRecord.
     */
    @Test
    public void testSet() {
        System.out.println("set");
        String line = "";
        BowTieRecord instance2 = new BowTieRecord();
        instance2.set(line);
        String result = instance2.get();
        assertEquals(line, result);
    }

    /**
     * Test of get method, of class BowTieRecord.
     */
    @Test
    public void testGet() {
        System.out.println("get");
        String expResult = line;
        String result = instance.get();
        assertEquals(expResult, result);
    }

    /**
     * Test of getMismatches method, of class BowTieRecord.
     */
    @Test
    public void testGetMismatches() {
        System.out.println("getMismatches");
        int expResult = 2;
        int result = instance.getMismatches();
        assertEquals(expResult, result);
    }

    /**
     * Test of getQuality method, of class BowTieRecord.
     */
    @Test
    public void testGetQuality() {
        System.out.println("getQuality");
        String expResult = "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII";
        String result = instance.getQuality();
        assertEquals(expResult, result);
    }

    /**
     * Test of getQuery_id method, of class BowTieRecord.
     */
    @Test
    public void testGetQuery_id() {
        System.out.println("getQuery_id");
        String expResult = "HWI-EAS127_3_4_1_774_879";
        String result = instance.getQueryID();
        assertEquals(expResult, result);
    }

    /**
     * Test of getQuery_sequence method, of class BowTieRecord.
     */
    @Test
    public void testGetQuery_sequence() {
        System.out.println("getQuery_sequence");
        String expResult = "AANTTGACCGCCTGGGGAGTACGGTCGCAAGATTAAAACTC";
        String result = instance.getQuery_sequence();
        assertEquals(expResult, result);
    }

    /**
     * Test of getStrand method, of class BowTieRecord.
     */
    @Test
    public void testGetStrand() {
        System.out.println("getStrand");
        instance.set(line);
        char expResult = '-';
        char result = instance.getStrand();
        assertEquals(expResult, result);
        instance.set(line2);
        result = instance.getStrand();
        assertEquals('-', result);
        instance.set(line3);
        result = instance.getStrand();
        assertEquals('-', result);
        instance.set(line4);
        result = instance.getStrand();
        assertEquals('+', result);
        instance.set(line5);
        result = instance.getStrand();
        assertEquals('+', result);
        instance.set(line6);
        result = instance.getStrand();
        assertEquals('+', result);
    }

    
    @Test
    public void testGetStart() {
        System.out.println("getStart");
        instance.set(line);
        int expResult = 419225;
        int result = instance.getStart();
        assertEquals(expResult, result);
        instance.set(line2);
        result = instance.getStart();
        assertEquals(97695, result);
        instance.set(line3);
        result = instance.getStart();
        assertEquals(58284, result);
        instance.set(line4);
        result = instance.getStart();
        assertEquals(1786952, result);
        instance.set(line5);
        result = instance.getStart();
        assertEquals(2816493, result);
        instance.set(line6);
        result = instance.getStart();
        assertEquals(3048771, result);
    }

    @Test
    public void testGetEnd() {
        System.out.println("getEnd");
        instance.set(line);
        int expResult = 419185;
        int result = instance.getEnd();
        assertEquals(expResult, result);
        instance.set(line2);
        result = instance.getEnd();
        assertEquals(97655, result);
        instance.set(line3);
        result = instance.getEnd();
        assertEquals(58244, result);
        instance.set(line4);
        result = instance.getEnd();
        assertEquals(1786992, result);
        instance.set(line5);
        result = instance.getEnd();
        assertEquals(2816533, result);
        instance.set(line6);
        result = instance.getEnd();
        assertEquals(3048811, result);
    }
    /**
     * Test of getSubject_id method, of class BowTieRecord.
     */
    @Test
    public void testGetSubject_id() {
        System.out.println("getSubjectID");
        String expResult = "ctg93  [organism=Burkholderia cenocepacia AU 1054] [tech=wgs] [gcode=11] [strain=AU 1054]";
        String result = instance.getSubjectID();
        assertEquals(expResult, result);
    }

    /**
     * Test of getSubject_offset method, of class BowTieRecord.
     */
    @Test
    public void testGetSubject_offset() {
        System.out.println("getSubject_offset");
        int expResult = 419184;
        int result = instance.getSubject_offset();
        assertEquals(expResult, result);
    }

    /**
     * Test of getSubstitutions method, of class BowTieRecord.
     */
    @Test
    public void testGetSubstitutions() {
        System.out.println("getSubstitutions");
        String expResult = "38:G>N,37:C>A";
        String result = instance.getSubstitutions();
        assertEquals(expResult, result);
    }

    @Test
    public void testGetWeight(){
        System.out.println("getWeight");
        double expResult = 39 - 2 * 2;
        double result = instance.getWeight();
        assertEquals(expResult, result, 0.0001);
    }

}